﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HammerMUD.Commands;
using HammerMUD.Items;
using HammerMUD.Rooms;

namespace HammerMUD.Admin
{
    public class MakeItemCommand : Command
    {
        public MakeItemCommand()
        {
            Name = "makeitem";
            Help = "makeitem <item name>";
            SecurityLevel = SecurityLevel.Admin;
        }

        public override void Do(HammerMUD.System.User from, List<string> arguments)
        {
            if (arguments.Count == 1)
            {
                from.Send(Help);
                return;
            }

            Item newItem = new Item();
            newItem.ItemNumber = 1;

            foreach (Item i in HammerMUD.System.HammerMUD.Items)
            {
                if (i.ItemNumber > newItem.ItemNumber)
                {
                    newItem.ItemNumber = i.ItemNumber + 1;
                }
            }

            newItem.Room = from.UserAccount.CurrentCharacter.CurrentRoom;
            newItem.Room.Items.Add(newItem);
            newItem.Name = arguments[1];
            from.Send("You create " + newItem.Name);
            RoomUtilities.SendToRoom(from, from.UserAccount.CurrentCharacter.Name + " creates a " + newItem.Name);
            return;
        }
    }
}
